package com.gutai.admin;

import java.util.Arrays;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import com.gutai.admin.dao.BaseRepositoryFactoryBean;

/**
 * 启动类
 *
 */
@SpringBootApplication
//@ComponentScan(basePackages = { "com.gutai.admin.controller", "com.gutai.admin", "com.gutai.admin.service" })
//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) // 不自动创建DB连接
@EnableJpaRepositories(basePackages = { "com.gutai.admin.dao" }, repositoryFactoryBeanClass = BaseRepositoryFactoryBean.class)// 指定自定义的JPA工厂类
@EnableCaching(proxyTargetClass = true, mode = AdviceMode.ASPECTJ)
public class App 
{

    private static final Logger log = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            log.debug("Let's inspect the beans provided by Spring Boot:");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            for (String beanName : beanNames) {
                log.debug(beanName);
            }

        };
    }
}
